// decorator

function logParameter(target: any, propertyKey: string, index: number) {
  console.log('===========');
  console.log('target: ', target);
  console.log('propertyKey: ', propertyKey);
  console.log('index: ', index);
  console.log('===========');
}

/**
 *
 * @param {any} target
 * @param {string} propertyKey
 * @param {PropertyDecorator} descriptor
 */
function method(
  target: any,
  propertyKey: string,
  descriptor: PropertyDescriptor
) {
  console.log('===========');
  console.log('target: ', target);
  console.log('propertyKey: ', propertyKey);
  console.log('descriptor: ', descriptor);
  console.log('===========');
  // descriptor.writable = false;
}

class Person {
  name: string;

  constructor(name: string) {
    this.name = name;
  }

  @method
  say() {
    console.log(this.name, ' is saying.');
  }

  gretting(@logParameter name: string, @logParameter message: string) {
    return `${message}, ${name}`;
  }

  @method
  static run() {
    console.log('润');
  }
}

const p1 = new Person('ataola');
p1.say = function () {
  console.log('biu');
};
p1.say();
console.log(p1.gretting('ataola', 'hello'))
